package io.school;

import java.io.*;
import java.util.Scanner;

/**
 * @author haomin
 * @date 2022/06/13 14:12
 **/
public class changeStyle {
    public static void main(String[] args) throws IOException {
        File file = new File("C:\\Users\\86187\\IdeaProjects\\javaEE_learn\\src\\io\\school\\srt.java");
        Scanner name = new Scanner(System.in);
        //File dest = new File("C:\\Users\\86187\\IdeaProjects\\javaEE_learn\\src\\io\\" + name);
        File dest = new File("C:\\Users\\86187\\IdeaProjects\\javaEE_learn\\src\\io\\school\\dest.java");
        StringBuilder sb = new StringBuilder();
        Scanner in = new Scanner(file);

        while (in.hasNext()) {
            String s = in.nextLine();
            String s1 = s.trim();
            if (s1.equals("public class srt")) {
                sb.append("public class dest");
            } else if (s1.length() > 0 && s1.charAt(0) == '{') {
                sb.append(" {");
                if (s1.length() > 1)
                    sb.append("\r\n" + s.replace('{', ' '));

            } else {
                sb.append("\r\n" + s);
            }
        }
        in.close();

        PrintWriter writer = new PrintWriter(dest);
        writer.print(sb.toString());
        writer.close();
    }
}